package com.thread.model.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.thread.model.entity.UserDemo;
import com.thread.model.mapper.UserMapper;
import com.thread.model.service.IUserService;
import com.thread.thread.ThreadPoolDemo;
import com.thread.threadpool.RunnablePoolDemo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-31
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, UserDemo> implements IUserService {

    private final RunnablePoolDemo runnablePoolDemo;
    private final ThreadPoolDemo threadPoolDemo;

    @Override
    public void threadPool() {
        IPage<UserDemo> page = new Page<>(1, 10000);
        IPage<UserDemo> pageResult = this.lambdaQuery().page(page);
        List<UserDemo> records = pageResult.getRecords();
        runnablePoolDemo.userMove(records);
    }

    @Override
    public void threadDemo() {
        IPage<UserDemo> page = new Page<>(1, 10000);
        IPage<UserDemo> pageResult = this.lambdaQuery().page(page);
        List<UserDemo> records = pageResult.getRecords();
        threadPoolDemo.threadDemo(records);
    }
}
